﻿using System;
using System.Collections.Generic;
using System.Text;

namespace DotNetNinjaLibrary.Basics
{
	public struct Size : IEquatable<Size>
	{
		private int width;
		private int height;
		private int hashCode;

		public Size(int width, int height)
		{
			this.width = width;
			this.height = height;
			this.hashCode = width.GetHashCode() + 13 * height.GetHashCode();
		}

		public int Width { get { return this.width; } }
		public int Height { get { return this.height; } }

		public bool Equals(Size other)
		{
			return this.Width == other.Width && this.Height == other.Height;
		}

		public static bool operator ==(Size a, Size b)
		{
			return a.Equals(b);
		}

		public static bool operator !=(Size a, Size b)
		{
			return !a.Equals(b);
		}

		public override bool Equals(object obj)
		{
			return obj is Size && this.Equals((Size)obj);
		}

		public override int GetHashCode()
		{
			return this.hashCode;
		}

		public override string ToString()
		{
			return String.Format("({0}, {1})", Width, Height);
		}
	}
}